﻿Imports CupsApp.Data
Imports CupsApp.Service
Partial Public Class follow_up
    Inherits System.Web.UI.Page

    Public _service As CupsDomainService
    Public _data As FollowupInterview
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        _service = New CupsDomainService
        _data = New FollowupInterview
        lvlMsg.Text = ""
        If Not IsPostBack Then
            If IsNothing(Request.QueryString("clientID")) Then
                CType(Master.FindControl("lnkNewClient"), LinkButton).Enabled = False
                CType(Master.FindControl("lnkNewClient"), LinkButton).Text = "> New Client/Family <"
            Else
                Client_ID.Value = Request.QueryString("clientID")
                _data = _service.GetFollowupInterview(Client_ID.Value, Constants.FollowupInterview.THREE_MONTH_INTERVIEW)
                wwDataBinder1.DataBind()
            End If
        End If
    End Sub

#Region "Click Events"

    Protected Sub lnkPersonal_Click(ByVal sender As Object, ByVal e As EventArgs) Handles lnkPersonal.Click
        Response.Redirect(String.Format("personal.aspx?clientID={0}", Client_ID.Value))
    End Sub

    Protected Sub lnkBackground_Click(ByVal sender As Object, ByVal e As EventArgs) Handles lnkBackground.Click
        Response.Redirect(String.Format("background.aspx?clientID={0}", Client_ID.Value))
    End Sub

    Protected Sub lnkHealthLegal_Click(ByVal sender As Object, ByVal e As EventArgs) Handles lnkHealthLegal.Click
        Response.Redirect(String.Format("health_legal.aspx?clientID={0}", Client_ID.Value))
    End Sub

    Protected Sub lnkHousing_Click(ByVal sender As Object, ByVal e As EventArgs) Handles lnkHousing.Click
        Response.Redirect(String.Format("housing.aspx?clientID={0}", Client_ID.Value))
    End Sub

    Protected Sub lnkStatus_Click(ByVal sender As Object, ByVal e As EventArgs) Handles lnkStatus.Click
        Response.Redirect(String.Format("status.aspx?clientID={0}", Client_ID.Value))
    End Sub

    Protected Sub lnkExit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles lnkExit.Click
        Response.Redirect(String.Format("exit.aspx?clientID={0}", Client_ID.Value))
    End Sub

#End Region

    Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
        wwDataBinder1.Unbind()
        Dim interview As String
        If (CheckBox220.Checked) Then
            interview = Constants.FollowupInterview.THREE_MONTH_INTERVIEW
        ElseIf (CheckBox221.Checked) Then
            interview = Constants.FollowupInterview.SIX_MONTH_INTERVIEW
        Else
            interview = Constants.FollowupInterview.NINE_MONTH_INTERVIEW
        End If
        _service.UpdateFollowupInterview(Client_ID.Value, interview, _data)
        lvlMsg.Text = "* Follow-Up information was saved successfully!"
    End Sub




    Protected Sub CheckBox220_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles CheckBox220.CheckedChanged
        Dim check As CheckBox = sender
        If (check.Checked) Then
            _data = _service.GetFollowupInterview(Client_ID.Value, Constants.FollowupInterview.THREE_MONTH_INTERVIEW)
            wwDataBinder1.DataBind()
            CheckBox221.Checked = False
            CheckBox222.Checked = False
        End If
    End Sub

    Protected Sub CheckBox221_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles CheckBox221.CheckedChanged
        Dim check As CheckBox = sender
        If (check.Checked) Then
            _data = _service.GetFollowupInterview(Client_ID.Value, Constants.FollowupInterview.SIX_MONTH_INTERVIEW)
            wwDataBinder1.DataBind()
            CheckBox220.Checked = False
            CheckBox222.Checked = False
        End If
    End Sub

    Protected Sub CheckBox222_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles CheckBox222.CheckedChanged
        Dim check As CheckBox = sender
        If (check.Checked) Then
            _data = _service.GetFollowupInterview(Client_ID.Value, Constants.FollowupInterview.NINE_MONTH_INTERVIEW)
            wwDataBinder1.DataBind()
            CheckBox220.Checked = False
            CheckBox221.Checked = False
        End If
    End Sub
End Class